package com.transportation.app.activity

import android.annotation.SuppressLint
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.os.Bundle
import android.widget.Toast
import androidx.fragment.app.FragmentActivity
import com.transportation.app.R
import com.transportation.app.see.SseManager
import org.greenrobot.eventbus.EventBus

class MainActivity : FragmentActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main_layout)
        EventBus.getDefault().register(this)
    }

    @SuppressLint("SetTextI18n")
    private fun initView() {

    }

    fun copyTextToClipboard(context: Context, text: String?) {
        // 获取系统服务来获取ClipboardManager实例
        val clipboard: ClipboardManager =
            context.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
        // 创建一个ClipData对象，其中包含要复制的文本
        val clip = ClipData.newPlainText("label", text)
        // 将ClipData对象设置到剪贴板中
        clipboard.setPrimaryClip(clip)
        // 显示一个提示，告知用户文本已被复制
        Toast.makeText(context, "文本已复制到剪贴板", Toast.LENGTH_SHORT).show()
    }

    private fun initListener() {

    }

    private val seeManager = SseManager()

    override fun onDestroy() {
        super.onDestroy()
        EventBus.getDefault().unregister(this)
    }


}